<template>
  <el-dialog v-model="dialogVisible" title="报告" width="800">
    <div>
      <div class="f12">
        {{ detailsData.studentName }} - {{ detailsData.gkaProvinceName }} -
        {{ detailsData?.student?.sex == 1 ? '女' : '男' }}
      </div>
    </div>
    <el-table
      :data="judgeResInfo"
      style="width: 100%"
      stripe
      v-loading="diaLoading"
    >
      <el-table-column type="index" />
      <el-table-column prop="name" label="测评项" />
      <el-table-column prop="date" label="测评时间" />
      <el-table-column label="操作">
        <template #default="scope">
          <el-button
            class="btns"
            size="small"
            type="primary"
            link
            @click="pingInfo(scope.row)"
            >查看</el-button
          >
          <el-button
            class="btns"
            size="small"
            type="primary"
            link
            @click="handleMajorRecommend(scope.row)"
            >专业推荐</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="dialogVisible = false">取消</el-button>
        <el-button type="primary" @click="dialogVisible = false">
          确认
        </el-button>
      </div>
    </template>
  </el-dialog>
  <downloadResult ref="downloadRef"></downloadResult>
</template>

<script setup>
import downloadResult from '../../../manage/appraisal/module/downloadResult.vue';
import { ref } from 'vue';
import {
  getPingList,
  // getJudgImgSave
} from '@/api/leader/Filling.js';
import { useRouter } from 'vue-router';
const router = useRouter();
const downloadRef = ref(null);

const props = defineProps({
  studentData: {
    type: Object,
    default: () => {},
  },
});

const dialogVisible = ref(false);
const diaLoading = ref(false);
const detailsData = ref({});
const judgeResInfo = ref([]);
const reqData = ref({
  page: 1,
  pageSize: 5,
});
const lookData = ref({});
const handleOpenReport = (data) => {
  dialogVisible.value = true;
  detailsData.value = data;
  reqData.value.studentMobile = data.studentMobile;
  reqData.value.studentId = data.studentId;
  (lookData.value.studentId = data.studentId), fetchPingList();
};
const handleMajorRecommend = (row) => {
  console.log(row);

  localStorage.setItem('student_data', JSON.stringify(props.studentData));
  router.push({
    path: '/leader/majorRecommend',
    query: {
      // sgid: row.sgid_pc,
      id: row.id,
    },
  });
};
const fetchPingList = () => {
  getPingList(reqData.value).then((res) => {
    judgeResInfo.value = res.data;
  });
};
const pingInfo = (data) => {
  lookData.value.id = data.id;
  lookData.value.type = '2';
  downloadRef.value.openChange(data);
  // fetchJudgImgSave();
};
// const fetchJudgImgSave = () => {
//   diaLoading.value = true;
//   getJudgImgSave(lookData.value)
//     .then((res) => {
//       if (res.code == 20000) {
//         diaLoading.value = false;
//         location.href = res.data.url;
//       } else {
//         diaLoading.value = false;
//       }
//     })
//     .catch(() => {
//       diaLoading.value = false;
//     });
// };
defineExpose({
  handleOpenReport,
});
</script>

<style lang="scss" scoped></style>
<style>
.el-dialog__header {
  border-bottom: 1px solid #e5e6e8;
  margin-right: 0px;
}
</style>
